<?php
    require_once("condb.php");
    require_once("functions.php");
    
    $output = array();
    $info = isset($_GET["info"]) ? $_GET["info"] : "";
    if(!empty($info)){
        $info = urldecode(base64_decode($info));
        parse_str($info, $request);    
        
        $token = isset($request["token"]) ? cleanQuery($request["token"]) : "";
        if($token=="TAoViEC@)!#2012"){        
            
            $data["type"] = isset($request["type"]) ? intval($request["type"]) : 0;
            
            if(!empty($data["type"])){
                $category = GetAllCategory($data["type"]);
                
                foreach($category as $i=>$row){                
                    $item[$i]["id"] = $row["id"]; 
                    $item[$i]["name"] = $row["name"];                 
                }
                
                $result = array();
                $result["type"] = "CATEGORY";            
                $result["action"]["type"] = "aURL";
                $result["action"]["url"] = "/Category.php";
                $result["item"] = isset($item) ? $item : null;
                
                $output["status"] = 1;
                $output["msg"] = "Success Request";    
            } else {
                $output["status"] = 3;
                $output["msg"] = "Invalid Request";
            }
                 
        } else {
            $output["status"] = 3;
            $output["msg"] = "Invalid Request";    
        }
    } else {
        $output["status"] = 2;
        $output["msg"] = "Invalid Request";
    }
            
    $output["data"] = isset($result) ? $result : array();

    echo json_encode($output);  
?>